<?php
	namespace app\controllers\demo_code;
	use yii\web\Controller;
	class DemoController extends Controller{
		public $enableCsrfValidation = false; 
		//重写actions类
		public function actions(){
			return [
				'captcha'=>[
					//初始化一个CaptchaAction类，并写验证码的一些参数
					'class' => 'yii\captcha\CaptchaAction',
						'maxLength'=>4,
						'minLength'=>4,
						'height'=>40,
						'width'=>80,
				],
			];
		}
		public function actionIndex(){
			$code = new \app\models\demo_code\code;
			return $this->render('view',['code'=>$code]);
		}
		public function actionTest(){
			
			$code = new \app\models\demo_code\code;
			if(\yii::$app->request->isPost && $code->load(\yii::$app->request->post())){
				$code->validate();
				
					print_r($code->getErrors());

			}
			
		}
	}
?>